<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__dept">
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
        style="width: 100%"
      >
        <el-table-column
          prop="guestName"
          label="客户姓名"
          align="center"
          :show-overflow-tooltip="true"
          min-width="120"
        ></el-table-column>
        <el-table-column
          prop="guestPhone"
          label="手机号"
          align="center"
          :show-overflow-tooltip="true"
          min-width="120"
        ></el-table-column>
        <el-table-column
          prop="orderAmount"
          label="订单总价"
          align="center"
          :show-overflow-tooltip="true"
          min-width="120"
        ></el-table-column>
        <el-table-column
          prop="realityPay"
          label="实付金额"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="orderTime"
          label="下单时间"
          header-align="center"
          align="center"
          min-width="180px"
        ></el-table-column>
        <el-table-column
          prop="num"
          label="共几晚"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="checkInRooms"
          label="房间数"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          :label="$t('handle')"
          fixed="right"
          header-align="center"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-button
              v-if="$hasPermission('guest:roomInfo:handleChange')"
              type="text"
              size="small"
              @click="
                num = scope.row.num;
                addOrUpdateHandle(scope.row.id);
              "
              >排房</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update
        v-if="addOrUpdateVisible"
        ref="addOrUpdate"
        :num="num"
        @refreshDataList="
          getDataList();
          refresTop();
        "
      ></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./exchangeTime-add-or-update";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/hotel/order/page",
        getDataListIsPage: true,
      },
      num: "",
      orderId: "",
      dataForm: {
        orderType: 202,
      },
    };
  },
  watch: {
    value1(newval, oldval) {
      if (newval) {
        if (newval != oldval) {
          this.dataForm.startDate = newval[0];
          this.dataForm.endDate = newval[1];
        }
      } else {
        this.dataForm.startDate = "";
        this.dataForm.endDate = "";
      }
    },
  },
  components: {
    AddOrUpdate,
  },
  methods: {
    refresTop() {
      this.$emit("refreshDataList");
    },
  },
};
</script>
